var express = require('express');
var router = express.Router();
var Post = require('../models/posts.js');
router.get("/",function(req,res,next){
    res.render('article',{});
});
router.post('/',function(req,res,next){
    var articleId = req.body['articleId'];
    Post.getOne(articleId,function(err,result,post){
        if(err){
            console.log('err'+err);
            res.json(err);
        }else if(result==="noTheArticle"){
            res.json({success:false,message:result,post:post});
        }else{
            res.json({success:true,message:result,post:post});
        }
    })
});

module.exports = router;